package com.demo2do.wechatmcs.entity.webauth;

import java.util.Date;
import java.util.Map;

import com.demo2do.core.persistence.annotation.ColumnMapping;
import com.demo2do.core.persistence.annotation.QueryTarget;

/**
 * 
 * @author mohanlan
 *
 */
@QueryTarget(table = "wechat_account")
public class WechatAccount {
    
    /** primary key */
    private Long id;

    /** 相当于关注时间或浏览时间 */
    @ColumnMapping(name = "create_time")
    private Date createTime;

    /** 腾讯字段: 用户的标识，对当前公众号唯一  */
    private String openid;

    /** 腾讯字段: 用户的昵称 */
    private String nickname;

    /** 
     *  腾讯字段: 用户的性别
     *  值为1时是男性，值为2时是女性，值为0时是未知 
     */
    private Integer sex;

    /** 腾讯字段: 用户所在省份 */
    private String province;

    /** 腾讯字段: 用户所在城市 */
    private String city;

    /** 腾讯字段: 用户所在国家 */
    private String country;

    /** 
     *  腾讯字段: 用户头像
     *  最后一个数值代表正方形头像大小（有0、46、64、96、132数值可选，0代表640*640正方形头像），用户没有头像时该项为空
     *  若用户更换头像，原有头像URL将失效
     */
    private String headimgurl;

    /** 腾讯字段: 只有在用户将公众号绑定到微信开放平台帐号后，才会出现该字段  */
    private String unionid;

    /** 腾讯字段: 用户的语言，简体中文为zh_CN */
    private String language;

    /** 腾讯字段: 用户关注时间，为时间戳。如果用户曾多次关注，则取最后关注时间 */
    @ColumnMapping(name = "subscribe_time")
    private Long subscribeTime;

    /** 腾讯字段: 公众号运营者对粉丝的备注，公众号运营者可在微信公众平台用户管理界面对粉丝添加备注 */
    private String remark;

    /** 腾讯字段: 用户所在的分组ID */
    private String groupid;
    
    /**
     * Default constructor
     */
    public WechatAccount() {
        
    }
    
    /**
     * @param data
     */
    public WechatAccount(Map<String, Object> data) {
        this.openid = data.containsKey("openid") ? data.get("openid").toString() : null;
        this.nickname = data.containsKey("nickname") ? data.get("nickname").toString() : null;
        this.sex = data.containsKey("sex") ? Integer.valueOf(data.get("sex").toString()) : 0;
        this.province = data.containsKey("province") ? data.get("province").toString() : null;
        this.city = data.containsKey("city") ? data.get("city").toString() : null;
        this.country = data.containsKey("country") ? data.get("country").toString() : null;
        this.headimgurl = data.containsKey("headimgurl") ? data.get("headimgurl").toString() : null;
        this.unionid = data.containsKey("unionid") ? data.get("unionid").toString() : null;
        this.language = data.containsKey("language") ? data.get("language").toString() : null;
        this.subscribeTime = data.containsKey("subscribe_time") ? Long.valueOf(data.get("subscribe_time").toString()): null;
        this.remark = data.containsKey("remark") ? data.get("remark").toString() : null;
        this.groupid = data.containsKey("groupid") ? data.get("groupid").toString() : null;
    }

    /**
     * 
     * @param id
     * @return
     */
    public WechatAccount editId(Long id) {
        this.id = id;
        return this;
    }

    
    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * @return the createTime
     */
    public Date getCreateTime() {
        return createTime;
    }

    /**
     * @return the openid
     */
    public String getOpenid() {
        return openid;
    }

    /**
     * @return the nickname
     */
    public String getNickname() {
        return nickname;
    }

    /**
     * @return the sex
     */
    public Integer getSex() {
        return sex;
    }

    /**
     * @return the province
     */
    public String getProvince() {
        return province;
    }

    /**
     * @return the city
     */
    public String getCity() {
        return city;
    }

    /**
     * @return the country
     */
    public String getCountry() {
        return country;
    }

    /**
     * @return the headimgurl
     */
    public String getHeadimgurl() {
        return headimgurl;
    }

    /**
     * @return the unionid
     */
    public String getUnionid() {
        return unionid;
    }

    /**
     * @return the language
     */
    public String getLanguage() {
        return language;
    }

    /**
     * @return the subscribeTime
     */
    public Long getSubscribeTime() {
        return subscribeTime;
    }

    /**
     * @return the remark
     */
    public String getRemark() {
        return remark;
    }

    /**
     * @return the groupid
     */
    public String getGroupid() {
        return groupid;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @param createTime the createTime to set
     */
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    /**
     * @param openid the openid to set
     */
    public void setOpenid(String openid) {
        this.openid = openid;
    }

    /**
     * @param nickname the nickname to set
     */
    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    /**
     * @param sex the sex to set
     */
    public void setSex(Integer sex) {
        this.sex = sex;
    }

    /**
     * @param province the province to set
     */
    public void setProvince(String province) {
        this.province = province;
    }

    /**
     * @param city the city to set
     */
    public void setCity(String city) {
        this.city = city;
    }

    /**
     * @param country the country to set
     */
    public void setCountry(String country) {
        this.country = country;
    }

    /**
     * @param headimgurl the headimgurl to set
     */
    public void setHeadimgurl(String headimgurl) {
        this.headimgurl = headimgurl;
    }

    /**
     * @param unionid the unionid to set
     */
    public void setUnionid(String unionid) {
        this.unionid = unionid;
    }

    /**
     * @param language the language to set
     */
    public void setLanguage(String language) {
        this.language = language;
    }

    /**
     * @param subscribeTime the subscribeTime to set
     */
    public void setSubscribeTime(Long subscribeTime) {
        this.subscribeTime = subscribeTime;
    }

    /**
     * @param remark the remark to set
     */
    public void setRemark(String remark) {
        this.remark = remark;
    }

    /**
     * @param groupid the groupid to set
     */
    public void setGroupid(String groupid) {
        this.groupid = groupid;
    }
    
}
